import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetDictionaryConfig_ {
  /**
   * @description 字典项名称
   * @example 指标业务部门
   */
  cnName?: string;
  /**
   * @description 页数
   * @format int32
   * @example 1
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   * @example 10
   */
  pageSize?: number;
}
export interface GetDictionaryConfigEnumTypeByEnumType_ {
  /**
   * @description 枚举类型英文大写
   */
  enumType: string;
}
export interface GetDictionaryConfigById_ {
  /**
   * @description 字典id
   */
  id: number;
}
export interface PutDictionaryConfigById_ {
  /**
   * @description 主键id
   */
  id: number;
}

export class DictionaryConfig {
  /**
   * 按字典名称搜索
   *
   * @tags 系统设置
   * @request GET: /dictionary-config
   * @secure
   */
  getDictionaryConfig = (
    query: { cnName?: string; pageNum?: number; pageSize?: number } | GetDictionaryConfig_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoDictionaryConfigVO>({
      url: `/dictionary-config`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 创建字典
   *
   * @tags 系统设置
   * @request POST: /dictionary-config
   * @secure
   */
  postDictionaryConfig = (body: defs.DictionaryConfigDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityDictionaryVO>({
      url: `/dictionary-config`,
      method: "POST",
      data: body,
      ...params,
    });

  /**
   * 根据字典类型查所有枚举
   *
   * @tags 系统设置
   * @request GET: /dictionary-config/enum-type/{enumType}
   * @secure
   */
  getDictionaryConfigEnumTypeByEnumType = (
    { enumType }: { enumType: string } | GetDictionaryConfigEnumTypeByEnumType_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListOptionVO>({
      url: `/dictionary-config/enum-type/${enumType}`,
      method: "GET",
      ...params,
    });

  /**
   * 根据id查所有枚举
   *
   * @tags 系统设置
   * @request GET: /dictionary-config/{id}
   * @secure
   */
  getDictionaryConfigById = ({ id }: { id: number } | GetDictionaryConfigById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListDictionaryEnumVO>({
      url: `/dictionary-config/${id}`,
      method: "GET",
      ...params,
    });

  /**
   * 更新字典
   *
   * @tags 系统设置
   * @request PUT: /dictionary-config/{id}
   * @secure
   */
  putDictionaryConfigById = (
    { id }: { id: number } | PutDictionaryConfigById_,
    body: defs.DictionaryConfigDTO,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityDictionaryVO>({
      url: `/dictionary-config/${id}`,
      method: "PUT",
      data: body,
      ...params,
    });
}

export default new DictionaryConfig();
